package com.gzx.risk.core.feign.response;

import lombok.Data;

import java.util.List;

@Data
public class MiniFeignResp {

    private Long code;
    private String msg;
    private ContractData data;

    @Data
    public static class ContractData {
        private String orderCode;
        private List<Contract> contracts;
        private UserIdCard userIdCard;
        private FaceRecognize face;
    }

    @Data
    public static class Contract {
        private String aliyunOssPath;
        private String aliyunOssFileName;
        private String aliyunOssHost;
        private Long contractId;
        private String status;

        public String getFullUrl() {
            if (aliyunOssHost == null || aliyunOssPath == null) {
                return null;
            }
            String host = aliyunOssHost.endsWith("/")
                    ? aliyunOssHost.substring(0, aliyunOssHost.length() - 1)
                    : aliyunOssHost;
            String path = aliyunOssPath.startsWith("/")
                    ? aliyunOssPath
                    : "/" + aliyunOssPath;
            return host + path;
        }
    }

    @Data
    public static class FaceRecognize{
        private String faceImage;
    }


    @Data
    public static class UserIdCard {
        private IdCardSide back;
        private IdCardSide face;
    }

    @Data
    public static class IdCardSide {
        private IdCardFields data;
        private String image;
    }

    @Data
    public static class IdCardFields {
        private FieldData issue;      // 签发机关
        private FieldData endDate;    // 有效期止
        private FieldData startDate;  // 有效期起

        private FieldData num;           // 身份证号
        private FieldData sex;           // 性别
        private FieldData name;          // 姓名
        private FieldData birth;         // 出生日期
        private FieldData address;       // 住址
        private FieldData nationality;   // 民族
    }

    @Data
    public static class FieldData {
        private String data;   // 实际值，如 "曾海兰"
        private String desc;   // 描述，如 "姓名"
    }
}
